using System;
using System.Collections.Generic;
using System.Text;
using BusinessObjects.BO_Actions.Articles;
using Entity.StoreProcedure;
using BusinessObjects;
using System.Data;
namespace BusinessObjects.BO_GetObjects
{
    public static class BO_Articles
    {
        public static DataTable SelectAll(int status)
        {
            try
            {
                BOArticles_Select_All action = new BOArticles_Select_All();
                usp_Articles_Select_All entity = new usp_Articles_Select_All();
                entity.STATUS = status;
                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable BeforeInsert()//BeforeInsert(int category_id)
        {
            try
            {
                BOArticles_Before_Insert action = new BOArticles_Before_Insert();
                usp_Articles_Before_Insert entity = new usp_Articles_Before_Insert();
                //entity.CATEGORY_ID = category_id;
                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SearchLike(string keyword, int status, int category_id, int maxrecords, int startindex)
        {
            try
            {
                BOArticles_Search_Like action = new BOArticles_Search_Like();
                usp_Articles_Search_Like entity = new usp_Articles_Search_Like();
                entity.STATUS = status;
                entity.Keyword = keyword;
                entity.Category_ID = category_id;
                entity.MAXRECORDS = maxrecords;
                entity.STARTINDEX = startindex;
                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SearchLikeHome(string keyword, int status, int category_id, int maxrecords, int startindex)
        {
            try
            {
                BOArticles_Search_Like_Home action = new BOArticles_Search_Like_Home();
                usp_Articles_Search_Like_Home entity = new usp_Articles_Search_Like_Home();
                entity.STATUS = status;
                entity.Keyword = keyword;
                entity.Category_ID = category_id;
                entity.MAXRECORDS = maxrecords;
                entity.STARTINDEX = startindex;
                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SelectTop(int rows, int status)
        {
            try
            {
                BOArticles_Select_Top action = new BOArticles_Select_Top();
                usp_Articles_Select_Top entity = new usp_Articles_Select_Top();
                entity.NUMBERRECORD = rows;
                entity.STATUS = status;
                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable Search(int article_id)
        {
            try
            {
                BOArticles_Search action = new BOArticles_Search();
                usp_Articles_Search entity = new usp_Articles_Search();
                entity.ARTICLE_ID = article_id;
                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SelectWithPaged(int startIndex, int pageCount, int status)
        {
            try
            {
                BOArticles_Select_WithPaged action = new BOArticles_Select_WithPaged();
                usp_Articles_Select_WithPaged entity = new usp_Articles_Select_WithPaged();
                entity.STARTINDEX = startIndex;
                entity.MAXRECORDS = pageCount;
                entity.STATUS = status;
                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SelectWithPagedCategory(int startIndex, int pageCount, int status, int category_id)
        {
            try
            {
                BOArticles_Select_WithPaged_Category action = new BOArticles_Select_WithPaged_Category();
                usp_Articles_Select_WithPaged_Category entity = new usp_Articles_Select_WithPaged_Category();
                entity.STARTINDEX = startIndex;
                entity.MAXRECORDS = pageCount;
                entity.STATUS = status;
                entity.CATEGORY_ID = category_id;
                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SelectWithPagedCategoryDisplay(int startIndex, int pageCount, int status, int category_id)
        {
            try
            {
                BOArticles_Select_WithPaged_Category_Display action = new BOArticles_Select_WithPaged_Category_Display();
                usp_Articles_Select_WithPaged_Category_Display entity = new usp_Articles_Select_WithPaged_Category_Display();
                entity.STARTINDEX = startIndex;
                entity.MAXRECORDS = pageCount;
                entity.STATUS = status;
                entity.CATEGORY_ID = category_id;
                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SelectAllWithPagedCategory(int startIndex, int pageCount, int status, int category_id)
        {
            try
            {
                BOArticles_Select_All_WithPaged_Category action = new BOArticles_Select_All_WithPaged_Category();
                usp_Articles_Select_All_WithPaged_Category entity = new usp_Articles_Select_All_WithPaged_Category();
                entity.STARTINDEX = startIndex;
                entity.MAXRECORDS = pageCount;
                entity.STATUS = status;
                entity.CATEGORY_ID = category_id;
                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static string Insert(int category_id, string article_code, int article_type, string mutil_thumb_img, string thumb_img, string short_article_title, string short_article_title_eng, string full_article_title, string full_article_title_eng, string short_article_description, string short_article_description_eng, string full_article_description, string full_article_description_eng, string article_detail, string article_detail_eng, string tags, string meta_keyword, string meta_description, int total_download, int total_vote, int total_comment, int total_view, bool is_display_on_home_page, string module_id, DateTime created_date, string created_by, DateTime modify_date, string modify_by, int status)
        {
            try
            {
                BOArticles_Insert action = new BOArticles_Insert();
                usp_Articles_Insert entity = new usp_Articles_Insert();
                entity.CATEGORY_ID = category_id;
                entity.ARTICLE_CODE = article_code;
                entity.ARTICLE_TYPE = article_type;
                entity.MUTIL_THUMB_IMG = mutil_thumb_img;
                entity.THUMB_IMG = thumb_img;
                entity.SHORT_ARTICLE_TITLE = short_article_title;
                entity.SHORT_ARTICLE_TITLE_ENG = short_article_title_eng;
                entity.FULL_ARTICLE_TITLE = full_article_title;
                entity.FULL_ARTICLE_TITLE_ENG = full_article_title_eng;
                entity.SHORT_ARTICLE_DESCRIPTION = short_article_description;
                entity.SHORT_ARTICLE_DESCRIPTION_ENG = short_article_description_eng;
                entity.FULL_ARTICLE_DESCRIPTION = full_article_description;
                entity.FULL_ARTICLE_DESCRIPTION_ENG = full_article_description_eng;
                entity.ARTICLE_DETAIL = article_detail;
                entity.ARTICLE_DETAIL_ENG = article_detail_eng;
                entity.TAGS = tags;
                entity.META_KEYWORD = meta_keyword;
                entity.META_DESCRIPTION = meta_description;
                entity.TOTAL_DOWNLOAD = total_download;
                entity.TOTAL_VOTE = total_vote;
                entity.TOTAL_COMMENT = total_comment;
                entity.TOTAL_VIEW = total_view;
                entity.IS_DISPLAY_ON_HOME_PAGE = is_display_on_home_page;
                entity.MODULE_ID = module_id;
                entity.CREATED_DATE = created_date;
                entity.CREATED_BY = created_by;
                entity.MODIFY_DATE = modify_date;
                entity.MODIFY_BY = modify_by;
                entity.STATUS = status;
                return action.ExecuteAndReturnStringValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static string Update(Int64 article_id, int category_id, string article_code, int article_type, string mutil_thumb_img, string thumb_img, string short_article_title, string short_article_title_eng, string full_article_title, string full_article_title_eng, string short_article_description, string short_article_description_eng, string full_article_description, string full_article_description_eng, string article_detail, string article_detail_eng, string tags, string meta_keyword, string meta_description, int total_download, int total_vote, int total_comment, int total_view, bool is_display_on_home_page, string module_id, DateTime created_date, string created_by, DateTime modify_date, string modify_by, int status)
        {
            try
            {
                BOArticles_Update action = new BOArticles_Update();
                usp_Articles_Update entity = new usp_Articles_Update();
                entity.ARTICLE_ID = article_id;
                entity.CATEGORY_ID = category_id;
                entity.ARTICLE_CODE = article_code;
                entity.ARTICLE_TYPE = article_type;
                entity.MUTIL_THUMB_IMG = mutil_thumb_img;
                entity.THUMB_IMG = thumb_img;
                entity.SHORT_ARTICLE_TITLE = short_article_title;
                entity.SHORT_ARTICLE_TITLE_ENG = short_article_title_eng;
                entity.FULL_ARTICLE_TITLE = full_article_title;
                entity.FULL_ARTICLE_TITLE_ENG = full_article_title_eng;
                entity.SHORT_ARTICLE_DESCRIPTION = short_article_description;
                entity.SHORT_ARTICLE_DESCRIPTION_ENG = short_article_description_eng;
                entity.FULL_ARTICLE_DESCRIPTION = full_article_description;
                entity.FULL_ARTICLE_DESCRIPTION_ENG = full_article_description_eng;
                entity.ARTICLE_DETAIL = article_detail;
                entity.ARTICLE_DETAIL_ENG = article_detail_eng;
                entity.TAGS = tags;
                entity.META_KEYWORD = meta_keyword;
                entity.META_DESCRIPTION = meta_description;
                entity.TOTAL_DOWNLOAD = total_download;
                entity.TOTAL_VOTE = total_vote;
                entity.TOTAL_COMMENT = total_comment;
                entity.TOTAL_VIEW = total_view;
                entity.IS_DISPLAY_ON_HOME_PAGE = is_display_on_home_page;
                entity.MODULE_ID = module_id;
                entity.CREATED_DATE = created_date;
                entity.CREATED_BY = created_by;
                entity.MODIFY_DATE = modify_date;
                entity.MODIFY_BY = modify_by;
                entity.STATUS = status;
                return action.ExecuteAndReturnStringValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static bool Delete(int article_id)
        {
            try
            {
                BOArticles_Delete action = new BOArticles_Delete();
                usp_Articles_Delete entity = new usp_Articles_Delete();
                entity.ARTICLE_ID = article_id;
                return action.ExecuteAndReturnBooleanValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static bool Up(int article_id, int category_id, int status)
        {
            try
            {
                BOArticles_Up action = new BOArticles_Up();
                usp_Articles_Up entity = new usp_Articles_Up();
                entity.ARTICLE_ID = article_id;
                entity.Category_ID = category_id;
                entity.STATUS = status;
                return action.ExecuteAndReturnBooleanValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static bool Down(int article_id, int category_id, int status)
        {
            try
            {
                BOArticles_Down action = new BOArticles_Down();
                usp_Articles_Down entity = new usp_Articles_Down();
                entity.ARTICLE_ID = article_id;
                entity.Category_ID = category_id;
                entity.STATUS = status;
                return action.ExecuteAndReturnBooleanValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static bool Restore(int article_id)
        {
            try
            {
                BOArticles_Restore action = new BOArticles_Restore();
                usp_Articles_Restore entity = new usp_Articles_Restore();
                entity.ARTICLE_ID = article_id;
                return action.ExecuteAndReturnBooleanValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static bool IsHot(int article_id, int module_id)
        {
            try
            {
                BOArticles_IsHot action = new BOArticles_IsHot();
                usp_Articles_IsHot entity = new usp_Articles_IsHot();
                entity.ARTICLE_ID = article_id;
                entity.MODULE_ID = module_id;
                return action.ExecuteAndReturnBooleanValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static bool IsHome(int article_id)
        {
            try
            {
                BOArticles_IsHome action = new BOArticles_IsHome();
                usp_Articles_IsHome entity = new usp_Articles_IsHome();
                entity.ARTICLE_ID = article_id;
                return action.ExecuteAndReturnBooleanValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static string Update(Int64 article_id, int total_vote)
        {
            try
            {
                BOArticles_Update_Vote action = new BOArticles_Update_Vote();
                usp_Articles_Update_Vote entity = new usp_Articles_Update_Vote();
                entity.ARTICLE_ID = article_id;
                entity.TOTAL_VOTE = total_vote;
                return action.ExecuteAndReturnStringValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SelectByModule(int status, int startindex, int maxrecord, int module_id)
        {
            try
            {
                BOArticles_Select_Hot_WithPaged_By_Module action = new BOArticles_Select_Hot_WithPaged_By_Module();
                usp_Articles_Select_Hot_WithPaged_By_Module entity = new usp_Articles_Select_Hot_WithPaged_By_Module();
                entity.MAXRECORDS = maxrecord;
                entity.MODULE_ID = module_id;
                entity.STARTINDEX = startindex;
                entity.STATUS = status;
                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SelectByModuleAdmin(int status, int startindex, int maxrecord, int module_id)
        {
            try
            {
                BOArticles_Select_Hot_WithPaged_By_Module_Admin action = new BOArticles_Select_Hot_WithPaged_By_Module_Admin();
                usp_Articles_Select_Hot_WithPaged_By_Module_Admin entity = new usp_Articles_Select_Hot_WithPaged_By_Module_Admin();
                entity.MAXRECORDS = maxrecord;
                entity.MODULE_ID = module_id;
                entity.STARTINDEX = startindex;
                entity.STATUS = status;
                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static bool Order(int mid, string list_aid_order)
        {
            try
            {
                BOArticles_Order action = new BOArticles_Order();
                usp_Articles_Order entity = new usp_Articles_Order();
                entity.MID = mid;
                entity.LIST_AID_ORDER = list_aid_order;
                return action.ExecuteAndReturnBooleanValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SelectByModule(int module_id, int start, int maxrecord)
        {
            try
            {
                BOArticles_Select_By_Module action = new BOArticles_Select_By_Module();
                usp_Articles_Select_By_Module entity = new usp_Articles_Select_By_Module();
                entity.MODULE_ID = module_id;
                entity.STARTINDEX = start;
                entity.MAXRECORDS = maxrecord;
                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SelectByCategory(int category_id, int start, int maxrecord)
        {
            try
            {
                BOArticles_Select_By_Category action = new BOArticles_Select_By_Category();
                usp_Articles_Select_By_Category entity = new usp_Articles_Select_By_Category();
                entity.CATEGORY_ID = category_id;
                entity.STARTINDEX = start;
                entity.MAXRECORDS = maxrecord;
                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SelectAllByDate(string date, int category)
        {
            try
            {
                BOArticles_Select_All_By_Date action = new BOArticles_Select_All_By_Date();
                usp_Articles_Select_All_By_Date entity = new usp_Articles_Select_All_By_Date();
                entity.DATE = date;
                entity.CATEGORY_ID = category;
                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
}

